import 'package:flutter/material.dart';

extension IntFix on int {
  // eg: 200.px
  double get px {
    return ScreenHelper.getPx(toDouble());
  }
}

extension DoubleFix on double {
  double get px {
    return ScreenHelper.getPx(this);
  }
}

extension GapWidth on double {
  SizedBox get gapV {
    return SizedBox(width: this);
  }
}

extension GapHeight on double {
  SizedBox get gapH {
    return SizedBox(height: this);
  }
}

class ScreenHelper {
  static late MediaQueryData _mediaQueryData;
  static late double screenWith;
  static late double screenHeight;
  static late double ratio;

  static init(BuildContext context, {double baseWidth = 375}) {
    _mediaQueryData = MediaQuery.of(context);
    screenWith = _mediaQueryData.size.width;
    screenHeight = _mediaQueryData.size.height;
    ratio = screenWith / baseWidth;
  }

  static double getPx(double size) {
    return ScreenHelper.ratio * size;
  }
}

SizedBox hiSpace({double height = 1, double width = 1}) {
  return SizedBox(
    height: height,
    width: width,
  );
}

bool isNotEmpty(String? text) {
  return text?.isNotEmpty ?? false;
}

bool isEmpty(String? text) {
  return text?.isEmpty ?? true;
}
